<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <!-- <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> -->

    <!-- 路径可能跟我不一样，需要修改 -->
    <script src="../js/vue.global.js"></script>


</head>

<body>

    <div id="app">


        分数: <input type="text" v-model="score"> <br>
        数学的分数: <input type="text" v-model="scoreObject.mathScore"> <br>


        <div v-if="success">

            数据正常

        </div>
        <div v-else>
            异常数据
        </div>



    </div>


    <script>

        // let obj = {
        //     a: 100
        // }

        // obj.a = 200

        // obj = {

        // }





        Vue.createApp({
            data() {
                return {
                    score: 60,
                    success: true,
                    scoreObject: {
                        mathScore: 60
                    }
                }
            },
            watch: {
                // score(newVal, oldVal) {
                //     console.log("newVal, oldVal", newVal, oldVal);

                // }

                score(newVal) {
                    console.log("newVal", newVal);
                    console.log("typeof(newVal)", typeof (newVal));
                    console.log("newVal > 100", (newVal > 100));

                    if (parseInt(newVal) > 100) {
                        this.success = false
                    } else {
                        this.success = true
                    }

                },

                scoreObject: {
                    handler(newVal, oldVal) {
                        console.log("scoreObject: newVal, oldVal", newVal, oldVal);
                    },

                    //深度监听 ， scoreObject.mathScore == xxxx
                    deep: true
                }

            }



        }).mount("#app")

    </script>




</body>

</html>